use Flap qw/-m -s -w/;
use Data::Dumper;

my %esc = (
    "\t" => '\\t',
    "\n" => '\\n',
    "\r" => '\\r',
    '"'  => '\\"',
    '$'  => '\\$',
    '@'  => '\\@',
    '\\' => '\\\\',
);

my $qquote = sub{
    if($_[0] =~ /[\t\n\r"\$\@\\]/){
        (my $qq = $_[0]) =~ s/([\t\n\r"\$\@\\])/$esc{$1}/eg;
        return qq{"$qq"};
    }
    qq{"$_[0]"};
};

sub{
    shift;
    no warnings 'redefine';
    local *Data::Dumper::qquote = $qquote;
    Data::Dumper
        ->new([@_])
        ->Indent($Flap::Util::DUMP_INDENT)
        ->Pair(' => ')
        ->Quotekeys(0)
        ->Sortkeys(1)
        ->Terse(1)
        ->Useqq(1)
        ->Dump;

};
